import java.awt.*;
import java.applet.*;
import java.util.Date;

public class time_threads extends Applet implements Runnable {

	Thread th;
	TextField st;
	Date date;

	boolean running = true;

	public void init() {
		setLayout(new BorderLayout());
		st = new TextField();
		add(st, "Center");

		th = new Thread(this);
		th.start();

	}

	public void destroy() {
		running = false;
		th = null;

	}

	@Override
	public void run() {
		
		while(running)
		{
			date = new Date();
			String time = date.getHours() + ":"+date.getMinutes()+":"+date.getSeconds();
			st.setText(time);
			
			try
			{
				th.sleep(500);
			}
			catch(InterruptedException e)
			{
				
			}
		}

	}

}
